package com.lys.blog.controller;

import com.lys.blog.dao.pojo.Category;
import com.lys.blog.service.CategoryService;
import com.lys.blog.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("categorys")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping
    public Result listCategory() {
        return categoryService.findAll();
    }

    @GetMapping("/detail")
    public Result categoryDetail() {
        return categoryService.findCategoryDetail();
    }

    @GetMapping("/detail/{id}")
    public Result categoryDetailById(@PathVariable Long id) {
        return categoryService.findCategoryDetailById(id);
    }


    @PostMapping
    public Result category(@RequestBody Category category){
        System.out.println(category.getId());
        return Result.success(null);
    }

}
